﻿using Orleans;
using Pay.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Pay.Model;
using Pay.Model.Interfaces;
using Pay.Dal;
using Pay.Container;
using Pay.Model.Dto;
using Pay.Model.Model;

namespace Pay.ServiceImplement
{
   public  class AliaccountServiceImplement : Grain, IAliaccountService
    {
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<bool> Update(AliAccountInfo model)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.Update(model);

        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<long> Add(AliAccountInfo model)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.Add(model);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<bool> Delete(AliAccountInfo model)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.Delete(model);
        }
        /// <summary>
        /// 停用
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<bool> Forbidden(AliAccountInfo model)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.Forbidden(model);
        }
        /// <summary>
        /// 根据id获取账号
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task<AliAccountInfo> GetAccountById(long Id)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.GetAccountById(Id);
        }

        public async Task<IPagedOutput<AliAccountInfo>> GetPage(string searchWord, long userId, DateTime? timeBegin = null, DateTime? timeEnd = null, int offset = 10, int rows = 1)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.GetPage(searchWord, userId, timeBegin, timeEnd, offset, rows);
        }

        public async Task<long> Add(QRCodeInfo model)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
             return await instance.Add(model);
        }

        public async Task<bool> IsContainSystemAccount(string systmeName)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.IsContainSystemAccount(systmeName);
        }

        public async Task<AliAccountInfo> GetInfoBySystemName(string systemName)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            var info =await  instance.GetInfoBySystemName(systemName);
         
            return info;
        }

        public async Task<MerchantInfo> GetKeyByCode(string code)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.GetKeyByCode(code);
        }

        public async Task<List<QRCodeInfo>> GetByAmount(decimal amount, long[] ids)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
           return await instance.GetByAmount(amount, ids);
        }

        public async Task<List<AliAccountInfo>> GetAccountByUserId(long userId)
        {
            var instance = LocManager.Resolve<IAliAccountDal>();
            return await instance.GetAccountByUserId(userId);
        }
    }
}
